package _Pan3D.program.shaders
{
	import _Pan3D.program.Shader3D;
	
	public class GroundScanningHightShader extends Shader3D
	{
		public static var GROUND_SCANNING_HIGHT_SHADER:String = "GROUND_SCANNING_HIGHT_SHADER";
		public function GroundScanningHightShader()
		{
			vertex = 
				"m44 vt0, va0, vc4 \n" +
				"mov v1,vt0 \n"+
				
				"div vt2.z,vt0.z,vc8.x \n"+  //距离除以比值，
                "mul vt0.x,vt0.x,vt2.z \n"+  //将X,Y根据深度，重新纠正到正确隐射位置，目的，就是可以得到某一坐标的永恒位置
                "mul vt0.y,vt0.y,vt2.z \n"+
				
				"m44 vt1, vt0, vc0 \n" +
				"mov op, vt1 \n" +
				"mov v0, va1 \n" 
			
			fragment =
				"tex ft0, v0, fs0 <2d,clamp,repeat>\n"+
				
				"neg ft4.z,v1.z \n"+
			
				"abs ft4.z,ft4.z\n"+           //存入深度
				"mov ft0.z,fc5.w\n"+
				"div ft4.z,ft4.z,fc5.x \n"+
				"frc ft0.x,ft4.z\n"+         //得到第一位存在X
				"sub ft4.z,ft4.z,ft0.x\n"+
				"div ft4.z,ft4.z,fc5.x\n"+
				"frc ft0.y,ft4.z\n"+         //得到第二位存在y
				
				"mov oc, ft0"
		}
	}
}